//
//  HNHappyTimeSectionView.m
//  XDEducation
//
//  Created by 星道 on 17/8/2.
//  Copyright © 2017年 apple. All rights reserved.
//

#import "HNHappyTimeSectionView.h"

@implementation HNHappyTimeSectionView
{
    IBOutlet UIImageView *_LeftImg;
    IBOutlet UILabel *_Title;
    HNHappyTimeSectionModel *_Model;
    void(^_Select)(HNHappyTimeSectionModel *Model);
}

- (instancetype)initWithModel:(HNHappyTimeSectionModel *)Model Identifier:(NSString *)Identifier Select:(void (^)(HNHappyTimeSectionModel *))Select
{
    self = [[[NSBundle mainBundle] loadNibNamed:[HNHappyTimeSectionView description] owner:nil options:nil] lastObject];
    if (self)
    {
        _Title.text = Model.Title;
        _Model = Model;
        _Select = Select;

        if (Model.IsOpen)
        {
            _LeftImg.transform = CGAffineTransformMakeRotation(M_PI/2);
        }
        else
        {
            _LeftImg.transform = CGAffineTransformIdentity;
        }
        [self addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(ClickTap:)]];
    }
    return self;
}

- (void)ClickTap:(UITapGestureRecognizer *)Tap
{
    if (_Select)
    {
        _Select (_Model);
    }
}
@end
